<script setup>
function execAsyncFun1(){
    async function asyncFun1(){
        return "helloAsync";
    }

    console.log(asyncFun1())    // Promise {<resolved>: "helloAsync"}
 
    asyncFun1().then(v=>{
        console.log(v);         // helloAsync
    })
}

function execAsyncFun2(){
    function testAwait(){
        return new Promise((resolve) => {
            setTimeout(function(){
                console.log("testAwait");
                resolve();
            }, 1000);
        });
    }
    
    async function helloAsync(){
        await testAwait();
        console.log("helloAsync");
    }
    helloAsync();
    // testAwait
    // helloAsync
}

function execAsyncFun3(){
    function testAwait (x) {
        return new Promise(resolve => {
            setTimeout(() => {
            resolve(x);
            }, 2000);
        });
    }
    
    async function helloAsync() {
        var x = await testAwait ("hello world");
        console.log(x); 
    }
    helloAsync ();
    // hello world
}
</script>
<template>
    <button @click="execAsyncFun3">按钮</button>
</template>